<?php

require_once 'BaseWidget.class.php';

class SelectWidget extends BaseWidget {
	public function doRender($name, $value = null, $attributes = array()) {
		extract($this->options);
		
		$optionsHtml = '';
		foreach ($choices as $optvalue=>$opttext) {
			$optattributes = array(
				'value' => $optvalue
			);
			if ($optvalue == $value) {
				$optattributes['checked'] = 'checked';
			}
			$optionsHtml .= $this->renderTag(
				'option',
				$optattributes,
				$opttext
			);
		}
		
		return $this->renderTag('select', $attributes, $optionsHtml);
	}
}
